package com.zealcomm.ivcscustomer.utils

import com.zealcomm.annotations.SystemTraceType
import com.zealcomm.commonui.beans.SystemTraceBean
import com.zco.ivcs.customer.IvcsCustomer
import com.zealcomm.ivcscustomer.app.IvcsApplication

/**
 * 添加自定义留痕示例（这里发送的消息不影响正常的操作流程）
 */
object SystemTraceUtil {
    private lateinit var customer: IvcsCustomer

    fun init(customer: IvcsCustomer) {
        this.customer = customer
    }

    @JvmStatic
    fun addTrace(@SystemTraceType systemTraceType: String, vararg info: SystemTraceBean.Info) {
        var matched = true
        val systemTraceBean = SystemTraceBean()
        systemTraceBean.businessType = systemTraceType
        systemTraceBean.userId = IvcsApplication.getUserId()
        when (systemTraceType) {
            SystemTraceType.SEND_HAND_SIGN_LINK -> {
                systemTraceBean.info = info[0]
            }
            SystemTraceType.SEND_FORM_RESULT -> {
                systemTraceBean.info = info[0]
            }
            SystemTraceType.SEND_APPLICATION -> {
                systemTraceBean.info = info[0]
            }
            else -> {
                matched = false
            }
        }
        if (matched) {
            customer.sendCustomMessage(systemTraceBean, null)
        }
    }
}